package com.qyer.lxp.common.framework.contants;

/**
 * Created by jiangping on 16/5/30.
 */
public enum ClientErrorMessageEnum {

    CLIENT_RESPONSE_100(100,"Unknow Exception"),
    CLIENT_RESPONSE_200(200,"OK"),
    CLIENT_RESPONSE_204(204,"No Content"),
    CLIENT_RESPONSE_205(205,"Reset Content"),
    CLIENT_RESPONSE_400(400,"Bad Request"),
    CLIENT_RESPONSE_404(404,"not found"),
    CLIENT_RESPONSE_403(403,"forbidden"),
    CLIENT_RESPONSE_502(502,"Bad Gateway"),
    CLIENT_RESPONSE_503(503,"Service Unavailable"),
    CLIENT_RESPONSE_504(504,"Gateway Timeout"),
    CLIENT_RESPONSE_505(505,"HTTP Version Not Supported"),
    CLIENT_RESPONSE_506(506,"Wrong Token"),
    CLIENT_RESPONSE_507(507,"Wrong Supplierid"),
    CLIENT_RESPONSE_508(508,"Wrong params");

    private int code;
    private String message;

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    ClientErrorMessageEnum(int code, String message){
        this.code = code;
        this.message = message;
    }

    /**
     * 返回异常信息
     * @param code
     * @return
     */
    public static String getErrorMessage(int code){
        if(code <= 0){
            return CLIENT_RESPONSE_100.getMessage();
        }
        for(ClientErrorMessageEnum clientErrorMessageEnum : ClientErrorMessageEnum.values()){
            if(clientErrorMessageEnum.getCode() == code){
                return clientErrorMessageEnum.getMessage();
            }
        }
        return CLIENT_RESPONSE_100.getMessage();
    }
}
